/**
 * @description 定义通用状态数据对象
 */

import {
  deCodeApi,
  enCodeApi
} from "@/utils"
import _ from 'loadsh'

const initState = {
    token:'',
    userInfo:{},
    menuList:[]
}

export default {
  namespaced: true,
  state: _.cloneDeep(initState),
  getters: {
    token(_state) {
      return !!_state.token ? deCodeApi(_state.token) : ''
    },
    userInfo:_state => _state.userInfo,
    menuList:_state => _state.menuList
  },
  mutations: {
    setToken(_state, _token) {
      _state.token = enCodeApi(_token)
    },
    setUserInfo(_state,_userInfo){
        _state.userInfo = _userInfo
    },
    setMenuList(_state,_menuList){
        _state.menuList = _menuList
    },
    clear(_state){
        _state = _.cloneDeep(initState)
    }
  },
  actions: {

  },
}
